home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / VideoFolder 1.0a / Source / MoreFiles 1.4.1 / FileCopy.c < prev    next >
Text File  |  1995-12-21  |  19KB  |  543 lines

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    FileCopy: A robust, general purpose file copy routine.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support Emeritus
  7. **
  8. **    File:        FileCopy.c
  9. **
  10. **    Copyright © 1992-1995 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #include <Types.h>
  23. #include <Errors.h>
  24. #include <Memory.h>
  25. #include <Files.h>
  26. #include "MoreFiles.h"
  27. #include "MoreFilesExtras.h"
  28. #include "MoreDesktopMgr.h"
  29. #include "FileCopy.h"
  30.  
  31. /*****************************************************************************/
  32.  
  33. /* local constants */
  34.  
  35. /*    The deny-mode privileges to use when opening the source and destination files. */
  36.  
  37. enum
  38. {
  39.     srcCopyMode = dmRdDenyWr,
  40.     dstCopyMode = dmWrDenyRdWr
  41. };
  42.  
  43. /*    The largest (16K) and smallest (.5K) copy buffer to use if the caller doesn't supply 
  44. **    their own copy buffer. */
  45.  
  46. enum
  47. {
  48.     bigCopyBuffSize  = 0x00004000,
  49.     minCopyBuffSize  = 0x00000200
  50. };
  51.  
  52. /*****************************************************************************/
  53.  
  54. /* static prototypes */
  55.  
  56. static    OSErr    GetDestinationDirInfo(short vRefNum,
  57.                                       long dirID,
  58.                                       StringPtr name,
  59.                                       long *theDirID,
  60.                                       Boolean *isDirectory,
  61.                                       Boolean *isDropBox);
  62. /*    GetDestinationDirInfo tells us if the destination is a directory, it's
  63.     directory ID, and if it's an AppleShare drop box (write privileges only --
  64.     no read or search privileges).
  65.     vRefNum        input:    Volume specification of the file's current
  66.                             location.
  67.     dirID        input:    Directory ID of the file's current location.
  68.     name        input:    The name of the file.
  69.     theDirID    output:    If the object is a file, then its parent directory
  70.                         ID. If the object is a directory, then its ID.
  71.     isDirectory    output:    True if object is a directory; false if
  72.                         object is a file.
  73.     isDropBox    output:    True if directory is an AppleShare drop box.
  74. */
  75.  
  76. static    OSErr    CheckForForks(short vRefNum,
  77.                               long dirID,
  78.                               ConstStr255Param name,
  79.                               Boolean *hasDataFork,
  80.                               Boolean *hasResourceFork);
  81. /*    CheckForForks tells us if there is a data or resource fork to copy.
  82.     vRefNum        input:    Volume specification of the file's current
  83.                             location.
  84.     dirID        input:    Directory ID of the file's current location.
  85.     name        input:    The name of the file.
  86. */
  87.  
  88. static    OSErr    PreflightFileCopySpace(short srcVRefNum,
  89.                                        long srcDirID,
  90.                                        ConstStr255Param srcName,
  91.                                        StringPtr dstVolName,
  92.                                        short dstVRefNum,
  93.                                        Boolean *spaceOK);
  94. /*    PreflightFileCopySpace determines if there's enough space on a
  95.     volume to copy the specified file to that volume.
  96.     Note: The results of this routine are not perfect. For example if the
  97.     volume's catalog or extents overflow file grows when the new file is
  98.     created, more allocation blocks may be needed beyond those needed for
  99.     the file's data and resource forks.
  100.  
  101.     srcVRefNum        input:    Volume specification of the file's current
  102.                             location.
  103.     srcDirID        input:    Directory ID of the file's current location.
  104.     srcName            input:    The name of the file.
  105.     dstVolName        input:    A pointer to the name of the volume where
  106.                             the file will be copied or NULL.
  107.     dstVRefNum        input:    Volume specification indicating the volume
  108.                             where the file will be copied.
  109.     spaceOK            output:    true if there's enough space on the volume for
  110.                             the file's data and resource forks.
  111. */
  112.  
  113. /*****************************************************************************/
  114.  
  115. static    OSErr    GetDestinationDirInfo(short vRefNum,
  116.                                       long dirID,
  117.                                       StringPtr name,
  118.                                       long *theDirID,
  119.                                       Boolean *isDirectory,
  120.                                       Boolean *isDropBox)
  121. {
  122.     CInfoPBRec pb;
  123.     Str31 tempName;
  124.     OSErr error;
  125.  
  126.     /* Protection against File Sharing problem */
  127.     if ( (name == NULL) || (name[0] == 0) )
  128.     {
  129.         tempName[0] = 0;
  130.         pb.dirInfo.ioNamePtr = tempName;
  131.         pb.dirInfo.ioFDirIndex = -1;    /* use ioDirID */
  132.     }
  133.     else
  134.     {
  135.         pb.dirInfo.ioNamePtr = name;
  136.         pb.dirInfo.ioFDirIndex = 0;    /* use ioNamePtr and ioDirID */
  137.     }
  138.     pb.dirInfo.ioVRefNum = vRefNum;
  139.     pb.dirInfo.ioDrDirID = dirID;
  140.     pb.dirInfo.ioACUser = 0;        /* ioACUser used to be filler2, clear it before calling GetCatInfo */
  141.     error = PBGetCatInfoSync(&pb);
  142.     *theDirID = pb.dirInfo.ioDrDirID;
  143.     *isDirectory = (pb.dirInfo.ioFlAttrib & ioDirMask) != 0;
  144.     /* see if access priviledges are make changes, not see folder, and not see files (drop box) */
  145.     *isDropBox = ((pb.dirInfo.ioACUser & 0x07) == 0x03);
  146.     return ( error );
  147. }
  148.  
  149. /*****************************************************************************/
  150.  
  151. static    OSErr    CheckForForks(short vRefNum,
  152.                               long dirID,
  153.                               ConstStr255Param name,
  154.                               Boolean *hasDataFork,
  155.                               Boolean *hasResourceFork)
  156. {
  157.     HParamBlockRec pb;
  158.     OSErr error;
  159.     
  160.     pb.fileParam.ioNamePtr = (StringPtr)name;
  161.     pb.fileParam.ioVRefNum = vRefNum;
  162.     pb.fileParam.ioFVersNum = 0;
  163.     pb.fileParam.ioDirID = dirID;
  164.     pb.fileParam.ioFDirIndex = 0;
  165.     error = PBHGetFInfoSync(&pb);
  166.     if ( error == noErr )
  167.     {
  168.         *hasDataFork = (pb.fileParam.ioFlLgLen != 0);
  169.         *hasResourceFork = (pb.fileParam.ioFlRLgLen != 0);
  170.     }
  171.     
  172.     return ( error );
  173. }
  174.  
  175. /*****************************************************************************/
  176.  
  177. static    OSErr    PreflightFileCopySpace(short srcVRefNum,
  178.                                        long srcDirID,
  179.                                        ConstStr255Param srcName,
  180.                                        StringPtr dstVolName,
  181.                                        short dstVRefNum,
  182.                                        Boolean *spaceOK)
  183. {
  184.     HParamBlockRec pb;
  185.     OSErr error;
  186.     Str255 tempPathname;
  187.     unsigned short dstFreeBlocks;
  188.     unsigned short dstBlksPerAllocBlk;
  189.     unsigned short srcDataBlks;
  190.     unsigned short srcResourceBlks;
  191.     
  192.     /* Get the number of 512 byte blocks per allocation block and */
  193.     /* number of free allocation blocks on the destination volume */
  194.     pb.volumeParam.ioVRefNum = dstVRefNum;
  195.     if ( dstVolName == NULL )
  196.     {
  197.         pb.volumeParam.ioNamePtr = NULL;
  198.         pb.volumeParam.ioVolIndex = 0;        /* use ioVRefNum only */
  199.     }
  200.     else
  201.     {
  202.         BlockMoveData(dstVolName, tempPathname, dstVolName[0] + 1);    /* make a copy of the string and */
  203.         pb.volumeParam.ioNamePtr = (StringPtr)tempPathname;    /* use the copy so original isn't trashed */
  204.         pb.volumeParam.ioVolIndex = -1;    /* use ioNamePtr/ioVRefNum combination */
  205.     }
  206.     error = PBHGetVInfoSync(&pb);
  207.     if ( error == noErr )
  208.     {
  209.         /* get allocation block size (always multiple of 512) and divide by 512
  210.           to get number of 512-byte blocks per allocation block */
  211.         dstBlksPerAllocBlk = ((unsigned long)pb.volumeParam.ioVAlBlkSiz >> 9);
  212.         dstFreeBlocks = (unsigned short)pb.volumeParam.ioVFrBlk;
  213.         
  214.         /* Now, get the size of the file's data resource forks */
  215.         pb.fileParam.ioNamePtr = (StringPtr)srcName;
  216.         pb.fileParam.ioVRefNum = srcVRefNum;
  217.         pb.fileParam.ioFVersNum = 0;
  218.         pb.fileParam.ioDirID = srcDirID;
  219.         pb.fileParam.ioFDirIndex = 0;
  220.         error = PBHGetFInfoSync(&pb);
  221.         if ( error == noErr )
  222.         {
  223.             /* get number of 512-byte blocks needed for data fork */
  224.             srcDataBlks = ((unsigned long)pb.fileParam.ioFlLgLen % 512) ?
  225.                           (((unsigned long)pb.fileParam.ioFlLgLen >> 9) + 1) :
  226.                           ((unsigned long)pb.fileParam.ioFlLgLen >> 9);
  227.             /* now, calculate number of new allocation blocks needed */
  228.             srcDataBlks = (srcDataBlks % dstBlksPerAllocBlk) ?
  229.                           ((srcDataBlks / dstBlksPerAllocBlk) + 1) :
  230.                           (srcDataBlks / dstBlksPerAllocBlk);
  231.         
  232.             /* get number of 512-byte blocks needed for resource fork */
  233.             srcResourceBlks = ((unsigned long)pb.fileParam.ioFlRLgLen % 512) ?
  234.                               (((unsigned long)pb.fileParam.ioFlRLgLen >> 9) + 1) :
  235.                               ((unsigned long)pb.fileParam.ioFlRLgLen >> 9);
  236.             /* now, calculate number of new allocation blocks needed */
  237.             srcResourceBlks = (srcResourceBlks % dstBlksPerAllocBlk) ?
  238.                               ((srcResourceBlks / dstBlksPerAllocBlk) + 1) :
  239.                               (srcResourceBlks / dstBlksPerAllocBlk);
  240.             
  241.             /* Is there enough room on the destination volume for the source file? */
  242.             *spaceOK = ((srcDataBlks + srcResourceBlks) <= dstFreeBlocks);
  243.         }
  244.     }
  245.     return ( error );
  246. }
  247.  
  248. /*****************************************************************************/
  249.  
  250. pascal    OSErr    FileCopy(short srcVRefNum,
  251.                          long srcDirID,
  252.                          ConstStr255Param srcName,
  253.                          short dstVRefNum,
  254.                          long dstDirID,
  255.                          StringPtr dstPathname,
  256.                          StringPtr copyName,
  257.                          void *copyBufferPtr,
  258.                          long copyBufferSize,
  259.                          Boolean preflight)
  260. {
  261.     OSErr    err;
  262.  
  263.     short    srcRefNum = 0,            /* 0 when source data and resource fork are closed  */
  264.             dstDataRefNum = 0,        /* 0 when destination data fork is closed */
  265.             dstRsrcRefNum = 0;        /* 0 when destination resource fork is closed */
  266.     
  267.     Str63    dstName;                /* The filename of the destination. It might be the
  268.                                     ** source filename, it might be a new name... */
  269.     
  270.     GetVolParmsInfoBuffer infoBuffer; /* Where PBGetVolParms dumps its info */
  271.     long    srcServerAdr;            /* AppleTalk server address of source (if any) */
  272.     
  273.     Boolean    dstCreated = false,        /* true when destination file has been created */
  274.             ourCopyBuffer = false,    /* true if we had to allocate the copy buffer */
  275.             isDirectory,            /* true if destination is really a directory */
  276.             isDropBox;                /* true if destination is an AppleShare drop box */
  277.     
  278.     long    tempLong;
  279.     short    tempInt;
  280.     
  281.     Boolean    spaceOK;                /* true if there's enough room to copy the file to the destination volume */
  282.  
  283.     Boolean    hasDataFork;
  284.     Boolean    hasResourceFork;
  285.  
  286.     /* Preflight for size */
  287.     if ( preflight )
  288.     {
  289.         err = PreflightFileCopySpace(srcVRefNum, srcDirID, srcName,
  290.                                      dstPathname, dstVRefNum, &spaceOK);
  291.         if ( err != noErr )
  292.             return ( err );
  293.         if ( !spaceOK )
  294.             return ( dskFulErr );
  295.     }
  296.  
  297.     /* get the destination's real dirID and make sure it really is a directory */
  298.     err = GetDestinationDirInfo(dstVRefNum, dstDirID, dstPathname,
  299.                                 &dstDirID, &isDirectory, &isDropBox);
  300.     if ( err != noErr )
  301.         goto ErrorExit;
  302.     if ( !isDirectory )
  303.         return ( dirNFErr );
  304.  
  305.     /* get the destination's real vRefNum */
  306.     err = DetermineVRefNum(dstPathname, dstVRefNum, &dstVRefNum);
  307.     if ( err != noErr )
  308.         goto ErrorExit;
  309.     
  310.     /* See if PBHCopyFile can be used.  Using PBHCopyFile saves time by letting the file server
  311.     ** copy the file if the source and destination locations are on the same file server. */
  312.     tempLong = sizeof(infoBuffer);
  313.     err = HGetVolParms((StringPtr)srcName, srcVRefNum, &infoBuffer, &tempLong);
  314.     if ( (err != noErr) && (err != paramErr) )
  315.         return ( err );
  316.  
  317.     if ( (err != paramErr) && hasCopyFile(infoBuffer) )
  318.     {
  319.         /* The source volume supports PBHCopyFile. */
  320.         srcServerAdr = infoBuffer.vMServerAdr;
  321.  
  322.         /* Now, see if the destination volume is on the same file server. */
  323.         tempLong = sizeof(infoBuffer);
  324.         err = HGetVolParms(NULL, dstVRefNum, &infoBuffer, &tempLong);
  325.         if ( (err != noErr) && (err != paramErr) )
  326.             return ( err );
  327.         if ( (err != paramErr) && (srcServerAdr == infoBuffer.vMServerAdr) )
  328.         {
  329.             /* Source and Dest are on same server and PBHCopyFile is supported. Copy with CopyFile. */
  330.             err = HCopyFile(srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, NULL, copyName);
  331.             if ( err != noErr )
  332.                 goto ErrorExit;
  333.             
  334.             dstCreated = true;
  335.             
  336.             /* AppleShare's CopyFile clears the isAlias bit, so I still need to attempt to copy
  337.                the File's attributes to attempt to get things right. */
  338.             if ( copyName != NULL )                /* Did caller supply copy file name? */
  339.             {
  340.                 /* Yes, use the caller supplied copy file name. */
  341.                 return ( CopyFileMgrAttributes(srcVRefNum, srcDirID, (StringPtr)srcName,
  342.                                              dstVRefNum, dstDirID, copyName, true) );
  343.             }
  344.             else
  345.             {
  346.                 /* They didn't, so get the source file name and use it. */
  347.                 if ( GetFilenameFromPathname(srcName, dstName) == noErr )
  348.                 {
  349.                     /* */
  350.                     return ( CopyFileMgrAttributes(srcVRefNum, srcDirID, (StringPtr)srcName,
  351.                                                  dstVRefNum, dstDirID, dstName, true) );
  352.                 }
  353.             }
  354.         }
  355.     }
  356.  
  357.     /* If we're here, then PBHCopyFile couldn't be used so we have to copy the file by hand. */
  358.  
  359.     /* Make sure a copy buffer is allocated. */
  360.     if ( copyBufferPtr == NULL )
  361.     {
  362.         /* The caller didn't supply a copy buffer so grab one from the application heap.
  363.         ** Try to get a big copy buffer, if we can't, try for a 512-byte buffer.
  364.         ** If 512 bytes aren't available, we're in trouble. */
  365.         copyBufferSize = bigCopyBuffSize;
  366.         copyBufferPtr = NewPtr(copyBufferSize);
  367.         if ( copyBufferPtr == NULL )
  368.         {
  369.             copyBufferSize = minCopyBuffSize;
  370.             copyBufferPtr = NewPtr(copyBufferSize);
  371.             if ( copyBufferPtr == NULL )
  372.                 return ( memFullErr );
  373.         }
  374.         ourCopyBuffer = true;
  375.     }
  376.  
  377.     /* Open the source data fork. */
  378.     err = HOpenAware(srcVRefNum, srcDirID, srcName, srcCopyMode, &srcRefNum);
  379.     if ( err != noErr )
  380.         goto ErrorExit;
  381.     
  382.     /* See if the copy will be renamed. */
  383.     if ( copyName != NULL )                /* Did caller supply copy file name? */
  384.         BlockMoveData(copyName, dstName, copyName[0] + 1);    /* Yes, use the caller supplied copy file name. */
  385.     else
  386.     {    /* They didn't, so get the source file name and use it. */
  387.         err = GetFileLocation(srcRefNum, &tempInt, &tempLong, (StringPtr)&dstName);
  388.         if ( err != noErr )
  389.             goto ErrorExit;
  390.     }
  391.  
  392.     /* Create the destination file. */
  393.     err = HCreateMinimum(dstVRefNum, dstDirID, dstName);
  394.     if ( err != noErr )
  395.         goto ErrorExit;
  396.     dstCreated = true;    /* After creating the destination file, any
  397.                         ** error conditions should delete the destination file */
  398.  
  399.     /* An AppleShare dropbox folder is a folder for which the user has the Make Changes
  400.     ** privilege (write access), but not See Files (read access) and See Folders (search access).
  401.     ** Copying a file into an AppleShare dropbox presents some special problems. Here are the
  402.     ** rules we have to follow to copy a file into a dropbox:
  403.     ** • File attributes can be changed only when both forks of a file are empty.
  404.     ** • DeskTop Manager comments can be added to a file only when both forks of a file 
  405.     **   are empty.
  406.     ** • A fork can be opened for write access only when both forks of a file are empty.
  407.     ** So, with those rules to live with, we'll do those operations now while both forks
  408.     ** are empty. */
  409.  
  410.     if ( isDropBox )
  411.     {
  412.         /* We only set the file attributes now if the file is being copied into a
  413.         ** drop box. In all other cases, it is better to set the attributes last
  414.         ** so that if FileCopy is modified to give up time to other processes
  415.         ** periodicly, the Finder won't try to read any bundle information (because
  416.         ** the bundle-bit will still be clear) from a partially copied file. If the
  417.         ** copy is into a drop box, we have to set the attributes now, but since the
  418.         ** destination forks are opened with write/deny-read/deny-write permissions,
  419.         ** any Finder that might see the file in the drop box won't be able to open
  420.         ** its resource fork until the resource fork is closed.
  421.         **
  422.         ** Note: if you do modify FileCopy to give up time to other processes, don't
  423.         ** give up time between the time the destination file is created (above) and
  424.         ** the time both forks are opened (below). That way, you stand the best chance
  425.         ** of making sure the Finder doesn't read a partially copied resource fork.
  426.         */
  427.         /* Copy attributes but don't lock the destination. */
  428.         err = CopyFileMgrAttributes(srcVRefNum, srcDirID, (StringPtr)srcName,
  429.                                     dstVRefNum, dstDirID, (StringPtr)&dstName, false);
  430.         if ( err != noErr )
  431.             goto ErrorExit;
  432.     }
  433.  
  434.     /* Attempt to copy the comments while both forks are empty.
  435.     ** Ignore the result because we really don't care if it worked or not. */
  436.     (void) DTCopyComment(srcVRefNum, srcDirID, (StringPtr)srcName, dstVRefNum, dstDirID, (StringPtr)&dstName);
  437.  
  438.     /* See which forks we need to copy. By doing this, we won't create a data or resource fork
  439.     ** for the destination unless it's really needed (some foreign file systems such as
  440.     ** the ProDOS File System and Macintosh PC Exchange have to create additional disk
  441.     ** structures to support resource forks). */
  442.     err = CheckForForks(srcVRefNum, srcDirID, srcName, &hasDataFork, &hasResourceFork);
  443.     if ( err != noErr )
  444.         goto ErrorExit;    
  445.     
  446.     if ( hasDataFork )
  447.     {
  448.         /* Open the destination data fork. */
  449.         err = HOpenAware(dstVRefNum, dstDirID, dstName, dstCopyMode, &dstDataRefNum);
  450.         if ( err != noErr )
  451.             goto ErrorExit;
  452.     }
  453.  
  454.     if ( hasResourceFork )
  455.     {
  456.         /* Open the destination resource fork. */
  457.         err = HOpenRFAware(dstVRefNum, dstDirID, dstName, dstCopyMode, &dstRsrcRefNum);
  458.         if ( err != noErr )
  459.             goto ErrorExit;
  460.     }
  461.  
  462.     if ( hasDataFork )
  463.     {
  464.         /* Copy the data fork. */
  465.         err = CopyFork(srcRefNum, dstDataRefNum, copyBufferPtr, copyBufferSize);
  466.         if ( err != noErr )
  467.             goto ErrorExit;
  468.     
  469.         /* Close both data forks and clear reference numbers. */
  470.         FSClose(srcRefNum);
  471.         FSClose(dstDataRefNum);
  472.         srcRefNum = dstDataRefNum = 0;
  473.     }
  474.     else
  475.     {
  476.         /* Close the source data fork since it was opened earlier */
  477.         FSClose(srcRefNum);
  478.         srcRefNum = 0;
  479.     }
  480.  
  481.     if ( hasResourceFork )
  482.     {
  483.         /* Open the source resource fork. */
  484.         err = HOpenRFAware(srcVRefNum, srcDirID, srcName, srcCopyMode, &srcRefNum);
  485.         if ( err != noErr )
  486.             goto ErrorExit;
  487.     
  488.         /* Copy the resource fork. */
  489.         err = CopyFork(srcRefNum, dstRsrcRefNum, copyBufferPtr, copyBufferSize);
  490.         if ( err != noErr )
  491.             goto ErrorExit;
  492.     
  493.         /* Close both resource forks and clear reference numbers. */
  494.         FSClose(srcRefNum);
  495.         FSClose(dstRsrcRefNum);
  496.         srcRefNum = dstRsrcRefNum = 0;
  497.     }
  498.  
  499.     /* Get rid of the copy buffer if we allocated it. */
  500.     if ( ourCopyBuffer )
  501.         DisposePtr((Ptr)copyBufferPtr);
  502.  
  503.     /* Attempt to copy attributes again to set mod date.  Copy lock condition this time
  504.     ** since we're done with the copy operation.  This operation will fail if we're copying
  505.     ** into an AppleShare dropbox, so we don't check for error conditions. */
  506.     CopyFileMgrAttributes(srcVRefNum, srcDirID, (StringPtr)srcName,
  507.                             dstVRefNum, dstDirID, (StringPtr)&dstName, true);
  508.  
  509.     /* Hey, we did it! */
  510.     return ( noErr );
  511.     
  512. ErrorExit:
  513.     if ( srcRefNum != 0 )
  514.         FSClose(srcRefNum);        /* Close the source file */
  515.     if ( dstDataRefNum != 0 )
  516.         FSClose(dstDataRefNum);    /* Close the destination file data fork */
  517.     if ( dstRsrcRefNum != 0 )
  518.         FSClose(dstRsrcRefNum);    /* Close the destination file resource fork */
  519.     if ( dstCreated )
  520.         HDelete(dstVRefNum, dstDirID, dstName);    /* Delete dest file.  This may fail if the file 
  521.                                                    is in a "drop folder" */
  522.     if ( ourCopyBuffer )    /* dispose of any memory we allocated */
  523.         DisposePtr((Ptr)copyBufferPtr);
  524.     return ( err );
  525. }
  526.  
  527. /*****************************************************************************/
  528.  
  529. pascal    OSErr    FSpFileCopy(const FSSpec *srcSpec,
  530.                             const FSSpec *dstSpec,
  531.                             StringPtr copyName,
  532.                             void *copyBufferPtr,
  533.                             long copyBufferSize,
  534.                             Boolean preflight)
  535. {
  536.     return ( FileCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
  537.                      dstSpec->vRefNum, dstSpec->parID, (StringPtr)dstSpec->name,
  538.                      copyName, copyBufferPtr, copyBufferSize, preflight) );
  539. }
  540.  
  541. /*****************************************************************************/
  542.  
  543.